/* BYF Media Library — BYF brand (Brand Guide: Inter headlines, Nunito body;
   Brand Gold #A6802F, Forest Night Green #1A3D31, Light Gold #CFAA5F, Dark Grey #38383B,
   Deepest Green #192F23, Oatmeal #F2EDE8, Sage #42594F, Light Sage #92A9A2). Layout modelled on Stockpress. */
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-Variable.bff0f2e92c.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('/fonts/Nunito-Variable.61cb12bad1.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }
:root {
  --gold: #A6802F; --gold-light: #CFAA5F; --gold-tint: #F6EEDC; --green: #1A3D31; --green-deep: #192F23;
  --sage: #42594F; --sage-light: #92A9A2; --oat: #F2EDE8; --bg: #F7F5F2; --card: #FFFFFF; --ink: #38383B; --ink-soft: #6B6B70;
  --line: #E6E1DA; --danger: #B3412E; --ok: #2F7A55; --radius: 10px; --shadow: 0 1px 2px rgba(25,47,35,.06), 0 4px 14px rgba(25,47,35,.06);
  --head: 'Inter', system-ui, sans-serif; --body: 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--bg); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
h1, h2, h3, .head { font-family: var(--head); letter-spacing: .02em; }
[hidden] { display: none !important; }
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

/* Sidebar */
.sidebar { background: var(--green); color: #E9EFEA; display: flex; flex-direction: column; overflow-y: auto; }
.sb-logo { padding: 20px 20px 14px; display: block; }
.sb-logo img { width: 100%; max-width: 190px; display: block; }
.sb-app { font-family: var(--head); font-size: 10.5px; letter-spacing: .22em; color: var(--gold-light); margin: 2px 0 0 2px; font-weight: 700; }
.sb-section { padding: 6px 12px; }
.sb-title { font-family: var(--head); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--sage-light); padding: 14px 10px 6px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.sb-title button { background: none; border: 0; color: var(--sage-light); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.sb-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; color: #E9EFEA; cursor: pointer; text-align: left; font-size: 14.5px; text-decoration: none; }
.sb-item:hover { background: rgba(255,255,255,.07); }
.sb-item.active { background: rgba(207,170,95,.18); color: #fff; box-shadow: inset 3px 0 0 var(--gold-light); }
.sb-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sb-item .count { margin-left: auto; font-size: 12px; color: var(--sage-light); }
.sb-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-foot { margin-top: auto; padding: 14px 20px 18px; font-size: 12px; color: var(--sage-light); border-top: 1px solid rgba(255,255,255,.08); }
.sb-foot .demo { background: var(--gold); color: #fff; border-radius: 6px; padding: 6px 8px; margin-bottom: 10px; font-weight: 700; font-size: 11.5px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.search { flex: 1; display: flex; align-items: center; max-width: 820px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 6px; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(166,128,47,.15); background: #fff; }
.search select { border: 0; background: transparent; padding: 8px 6px 8px 10px; color: var(--ink-soft); font-size: 13.5px; border-right: 1px solid var(--line); outline: none; cursor: pointer; }
.search svg { width: 18px; height: 18px; margin: 0 6px 0 12px; color: var(--ink-soft); flex: none; }
.search input { flex: 1; border: 0; background: transparent; padding: 9px 8px; outline: none; font-size: 14.5px; min-width: 0; }
.search .clear { border: 0; background: none; cursor: pointer; color: var(--ink-soft); padding: 4px 10px; font-size: 18px; }
.topbar .spacer { flex: 1; }
.avatar { position: relative; flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--green); color: var(--oat); display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 13px; letter-spacing: .02em; border: 2px solid var(--gold-light); cursor: pointer; overflow: hidden; }
.avatar:hover, .avatar:focus-visible { box-shadow: 0 0 0 3px rgba(166,128,47,.25); outline: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.has-photo { background: var(--oat); }
.menu { position: absolute; right: 16px; top: 56px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; z-index: 50; padding: 6px; }
.menu .who { padding: 8px 10px; font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--bg); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 8px 14px; cursor: pointer; font-weight: 700; font-size: 13.5px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #cfc7bb; }
.btn svg { width: 16px; height: 16px; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #94711f; border-color: #94711f; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-ghost-light { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--ink-soft); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* Content layout: filter panel + results */
.content { flex: 1; display: flex; min-height: 0; }
.filters { width: 264px; flex: none; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 0 40px; }
.filters.closed { display: none; }
.f-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; }
.f-head h3 { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--green); }
.f-head button { border: 0; background: none; color: var(--gold); cursor: pointer; font-weight: 700; font-size: 12.5px; }
.f-group { border-top: 1px solid var(--line); }
.f-group > button { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border: 0; background: none; cursor: pointer; font-family: var(--head); font-weight: 600; font-size: 13px; color: var(--ink); }
.f-group > button .chev { transition: transform .15s; color: var(--ink-soft); }
.f-group.collapsed > button .chev { transform: rotate(-90deg); }
.f-group.collapsed .f-body { display: none; }
.f-body { padding: 0 14px 12px 18px; }
.f-opt { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; font-size: 14px; }
.f-opt input { accent-color: var(--gold); width: 15px; height: 15px; margin: 0; }
.f-opt .n { margin-left: auto; color: var(--ink-soft); font-size: 12px; }
.f-opt .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-more { border: 0; background: none; color: var(--gold); cursor: pointer; font-size: 12.5px; font-weight: 700; padding: 4px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 9px; cursor: pointer; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--green); color: #fff; border-color: var(--green); }
.seg button .n { font-size: 11px; opacity: .7; }
.seg svg { width: 14px; height: 14px; }
.tree { font-size: 14px; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 3px 0; cursor: pointer; border-radius: 6px; }
.tree-row:hover { background: var(--bg); }
.tree-row.on { background: var(--gold-tint); color: var(--green); font-weight: 700; }
.tree-row .tw { width: 16px; text-align: center; color: var(--ink-soft); font-size: 10px; border: 0; background: none; cursor: pointer; padding: 0; }
.tree-row .n { margin-left: auto; color: var(--ink-soft); font-size: 12px; padding-right: 4px; }
.tree-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-select { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.toggle { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; padding: 4px 0; }
.toggle input { accent-color: var(--gold); }

.results { flex: 1; overflow-y: auto; padding: 18px 24px 120px; min-width: 0; }
.r-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.r-title h1 { margin: 0; font-size: 22px; font-weight: 700; text-transform: uppercase; color: var(--green); letter-spacing: .04em; }
.r-title .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.r-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.r-tools select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13.5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--gold-tint); color: #6d521a; border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; font-weight: 700; }
.chip button { border: 0; background: rgba(0,0,0,.06); border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; font-size: 13px; color: inherit; }
.chips .link { border: 0; background: none; color: var(--gold); font-weight: 700; cursor: pointer; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; }
.chips .link svg { width: 14px; height: 14px; }

/* Asset grid (Stockpress-style cards) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 210px), 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; position: relative; cursor: pointer; transition: box-shadow .15s, transform .15s; outline: 2px solid transparent; }
.card:hover { box-shadow: 0 2px 4px rgba(25,47,35,.08), 0 10px 24px rgba(25,47,35,.12); }
.card.sel { outline: 3px solid var(--gold); }
.card .thumb { aspect-ratio: 4 / 3; background: #EEEAE4; position: relative; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid.fit .card .thumb img { object-fit: contain; }
.card .cb { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; margin: 0; border-radius: 6px; background: rgba(255,255,255,.92); border: 1.5px solid rgba(0,0,0,.2); display: grid; place-items: center; opacity: 0; transition: opacity .12s; z-index: 2; appearance: none; -webkit-appearance: none; cursor: pointer; }
.card .cb:checked { background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 16px no-repeat; border-color: var(--gold); opacity: 1; }
.card .card-open { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; }
.card .card-open:focus-visible, .card .cb:focus-visible, .card .hover-actions button:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.card:focus-within .cb, .card:focus-within .hover-actions { opacity: 1; }
.card .cb svg { width: 16px; height: 16px; color: #fff; display: none; }
.card.sel .cb { border-color: var(--gold); opacity: 1; }
.card.sel .cb svg { display: block; }
.card:hover .cb, .selecting .card .cb { opacity: 1; }
.card .hover-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; z-index: 2; }
.card:hover .hover-actions { opacity: 1; }
.card .hover-actions button { width: 30px; height: 30px; border-radius: 7px; border: 0; background: rgba(255,255,255,.94); cursor: pointer; display: grid; place-items: center; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.card .hover-actions button:hover { background: #fff; color: var(--gold); }
.card .hover-actions button svg { width: 16px; height: 16px; }
.card .fav-on { position: absolute; top: 10px; right: 10px; color: var(--gold-light); z-index: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.card:hover .fav-on { display: none; }
.card .fav-on svg { width: 18px; height: 18px; fill: currentColor; }
.badge { position: absolute; font-size: 11px; font-weight: 800; border-radius: 5px; padding: 3px 6px; letter-spacing: .03em; font-family: var(--head); }
.badge.dur { right: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; display: flex; align-items: center; gap: 4px; }
.badge.dur svg { width: 10px; height: 10px; fill: #fff; }
.badge.status { left: 8px; bottom: 8px; }
.st-select { background: var(--gold); color: #fff; }
.st-raw { background: #5d6b66; color: #fff; }
.st-do_not_use { background: var(--danger); color: #fff; }
.st-suggested { opacity: .78; border: 1px dashed rgba(255,255,255,.8); }
.badge.dup { left: 8px; top: 8px; background: #fff; color: var(--sage); }
.card:hover .badge.dup { display: none; }
.card .info { padding: 9px 12px 11px; }
.card .name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { color: var(--ink-soft); font-size: 12px; margin-top: 2px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.card .meta svg { width: 12px; height: 12px; flex: none; }
.card .tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: nowrap; overflow: hidden; }
.card .tags span { background: var(--oat); color: var(--sage); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.load-more { display: flex; justify-content: center; padding: 26px; color: var(--ink-soft); }
.empty { text-align: center; padding: 70px 20px; color: var(--ink-soft); }
.empty h2 { color: var(--green); text-transform: uppercase; font-size: 18px; }

/* Bottom action bar (multi-select) */
.actionbar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); width: max-content; background: var(--green-deep); color: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; gap: 4px; padding: 8px 10px 8px 18px; z-index: 40; max-width: calc(100vw - 40px); flex-wrap: wrap; }
.actionbar .count { font-family: var(--head); font-weight: 700; margin-right: 10px; white-space: nowrap; }
.actionbar button { border: 0; background: transparent; color: #fff; padding: 8px 11px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.actionbar button:hover { background: rgba(255,255,255,.1); }
.actionbar button svg { width: 16px; height: 16px; }
.actionbar .primary { background: var(--gold); }
.actionbar .primary:hover { background: #b8913c; }
.actionbar .sep { width: 1px; height: 24px; background: rgba(255,255,255,.18); margin: 0 4px; }

/* Single-file view */
.viewer { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: 1fr 400px; background: #111614; }
.v-stage { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; padding: 60px 70px 30px; }
.v-stage img, .v-stage video { max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain; box-shadow: 0 10px 40px rgba(0,0,0,.4); background: #000; }
.v-stage iframe { width: 100%; height: calc(100vh - 120px); border: 0; background: #000; }
.v-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 14px 18px; color: #fff; }
.v-top .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-top .pos { color: #9aa7a1; font-size: 13px; }
.v-top button { background: rgba(255,255,255,.08); border: 0; color: #fff; border-radius: 8px; padding: 7px 10px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-weight: 700; font-size: 13px; }
.v-top button:hover { background: rgba(255,255,255,.16); }
.v-top button svg { width: 16px; height: 16px; }
.v-top button.on svg { fill: var(--gold-light); color: var(--gold-light); }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.08); color: #fff; border: 0; width: 44px; height: 64px; border-radius: 10px; cursor: pointer; font-size: 28px; }
.v-nav:hover { background: rgba(255,255,255,.18); }
.v-prev { left: 14px; } .v-next { right: 14px; }
.v-side { background: #fff; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button { border: 0; background: none; padding: 15px 12px 13px; cursor: pointer; font-family: var(--head); font-weight: 600; font-size: 13px; color: var(--ink-soft); border-bottom: 2px solid transparent; letter-spacing: .02em; }
.tabs button.on { color: var(--green); border-bottom-color: var(--gold); }
.v-body { flex: 1; overflow-y: auto; padding: 18px 20px 30px; }
.field { margin-bottom: 16px; }
.field label, .field .flabel, .flabel, .lbl-sm { display: block; font-family: var(--head); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=password], .field input[type=date], .field input[type=number], .field textarea, .field select, .inp { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none; }
.field input:focus, .field textarea:focus, .inp:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(166,128,47,.13); }
.field textarea { min-height: 120px; resize: vertical; }
.status-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.status-pick button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 4px; cursor: pointer; font-size: 12.5px; font-weight: 700; }
.status-pick button.on.select { background: var(--gold); color: #fff; border-color: var(--gold); }
.status-pick button.on.raw { background: #5d6b66; color: #fff; border-color: #5d6b66; }
.status-pick button.on.do_not_use { background: var(--danger); color: #fff; border-color: var(--danger); }
.status-pick button.on.none { background: var(--oat); }
.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.hint.warn { color: #8a5a00; background: #FFF6E0; padding: 7px 9px; border-radius: 7px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 10px; font-size: 13.5px; }
.kv dt { color: var(--ink-soft); } .kv dd { margin: 0; word-break: break-word; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; background: var(--oat); color: var(--green); border-radius: 6px; padding: 5px 6px 5px 10px; font-size: 13px; font-weight: 700; }
.tag.ai { background: #E6EEEB; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: 14px; line-height: 1; padding: 0 2px; }
.add-row { display: flex; gap: 6px; margin-top: 10px; }
.add-row input { flex: 1; }
.dl-list { display: grid; gap: 8px; }
.dl-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dl-item .ratio { width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.dl-item .ratio i { display: block; border: 2px solid var(--green); border-radius: 3px; }
.dl-item .t { font-weight: 700; font-size: 13.5px; } .dl-item .s { font-size: 12px; color: var(--ink-soft); }
.dl-item .btn { margin-left: auto; }
.fit-toggle { display: flex; gap: 6px; margin: 4px 0 12px; }
.dup-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.dup-row img { width: 54px; height: 40px; object-fit: cover; border-radius: 5px; }

/* Modals */
.modal-back { position: fixed; inset: 0; background: rgba(17,22,20,.5); z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-h { padding: 18px 22px 8px; display: flex; align-items: center; }
.modal-h h2 { margin: 0; font-size: 16px; text-transform: uppercase; letter-spacing: .06em; color: var(--green); }
.modal-h .icon-btn { margin-left: auto; }
.modal-b { padding: 8px 22px 6px; overflow-y: auto; }
.modal-f { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.coll-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.coll-list label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.coll-list label:last-child { border-bottom: 0; }
.coll-list input { accent-color: var(--gold); }
.linkbox { display: flex; gap: 6px; }
.linkbox input { flex: 1; font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--bg); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.switch-row .t { font-weight: 700; font-size: 14px; } .switch-row .s { font-size: 12.5px; color: var(--ink-soft); }
.switch-row input[type=checkbox] { accent-color: var(--gold); width: 18px; height: 18px; }
.share-ok { background: #EEF6F1; border: 1px solid #CFE6D8; color: var(--ok); border-radius: 10px; padding: 10px 12px; font-weight: 700; margin-bottom: 12px; font-size: 13.5px; }

/* Collections page */
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.coll-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; position: relative; }
.coll-card:hover { box-shadow: 0 10px 24px rgba(25,47,35,.12); }
.mosaic { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 16/10; background: var(--oat); }
.mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic img:first-child { grid-row: span 2; }
.mosaic .ph { grid-column: span 2; grid-row: span 2; display: grid; place-items: center; color: var(--sage-light); overflow: hidden; }
.mosaic .ph svg { width: 40px; height: 40px; opacity: .75; }
.coll-card .info { padding: 11px 14px 13px; }
.coll-card .name { font-weight: 800; font-size: 15px; }
.coll-card .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.coll-card .meta svg { width: 13px; height: 13px; }
.coll-card .hover-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; }
.coll-card:hover .hover-actions { opacity: 1; }
.coll-card .hover-actions button { width: 30px; height: 30px; border-radius: 7px; border: 0; background: rgba(255,255,255,.94); cursor: pointer; display: grid; place-items: center; }
.coll-card .hover-actions svg { width: 16px; height: 16px; }

/* Tables */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-family: var(--head); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); padding: 12px 14px; border-bottom: 1px solid var(--line); background: #FBFAF8; font-weight: 600; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; }
.pill.active { background: #E5F2EA; color: var(--ok); } .pill.revoked, .pill.expired, .pill.limit_reached { background: #F7E5E1; color: var(--danger); }
.pill.lock { background: var(--gold-tint); color: #6d521a; }
.dup-group { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.dup-group .row { display: flex; gap: 14px; overflow-x: auto; }
.dup-group figure { margin: 0; width: 180px; flex: none; font-size: 12.5px; }
.dup-group figure img { width: 180px; height: 130px; object-fit: cover; border-radius: 8px; cursor: pointer; }
.dup-group figcaption { margin-top: 5px; color: var(--ink-soft); word-break: break-word; }
.dup-group figcaption b { color: var(--ink); display: block; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--green-deep); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 700; font-size: 13.5px; max-width: 380px; }
.toast.err { background: var(--danger); }

/* Login */
.login-body { background: var(--green) radial-gradient(circle at 50% 0%, #24503f 0%, var(--green) 60%); min-height: 100vh; display: grid; place-items: center; color: #fff; }
.login-card { text-align: center; max-width: 420px; padding: 40px 30px; }
.login-logo { width: 190px; margin-bottom: 18px; }
.login-card h1 { font-size: 15px; letter-spacing: .32em; color: var(--gold-light); margin: 0 0 14px; }
.login-card p { color: #D7E0DA; line-height: 1.5; margin: 0 0 24px; }
.login-error { background: rgba(179,65,46,.25); border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 10px; margin-bottom: 18px; }
.dev-login { margin-top: 28px; padding-top: 18px; border-top: 1px dashed rgba(255,255,255,.25); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dev-label { width: 100%; font-size: 12px; color: var(--gold-light); }
.dev-login input { padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; min-width: 240px; }
.login-foot { margin-top: 30px; font-size: 12px; color: var(--sage-light); }

@media (max-width: 1100px) { .filters { position: absolute; z-index: 30; height: calc(100vh - 62px); box-shadow: var(--shadow); } .viewer { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .app { grid-template-columns: 1fr; } }

/* ---- AI auto-tagging ---- */
.ai-ic { width: 13px; height: 13px; vertical-align: -2px; color: var(--gold); }
.ai-box { background: linear-gradient(180deg, #FBF7EE, #fff); border: 1px solid #EFE3C8; border-radius: var(--radius); padding: 12px 12px 10px; margin-bottom: 18px; }
.ai-box > label, .ai-box > .flabel { display: flex; align-items: center; gap: 6px; }
.ai-src { margin-left: auto; text-transform: none; letter-spacing: 0; font-family: var(--body); font-weight: 700; color: var(--sage-light); font-size: 11px; }
.tag.tag-ai { background: #fff; border: 1px dashed var(--gold-light); color: var(--green); padding: 4px 4px 4px 9px; }
.tag.tag-ai .conf { font-size: 11px; font-weight: 800; color: var(--gold); background: var(--gold-tint); border-radius: 4px; padding: 1px 5px; }
.tag.tag-ai button { width: 20px; height: 20px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.tag.tag-ai button:hover { background: var(--oat); color: var(--green); }
.tag.tag-ai button.ok svg { width: 13px; height: 13px; }
.tag.tag-ai button.ok:hover { background: #E5F2EA; color: var(--ok); }
.tag.tag-ai button.blk:hover { background: #F7E5E1; color: var(--danger); }
.tag.tag-ai-ok .ai-ic { margin-right: -1px; }
.tag.tag-blocked { background: #F7E5E1; color: var(--danger); }
.ai-text { margin-top: 12px; }
.ai-text pre { margin: 0; white-space: pre-wrap; font-family: var(--body); font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--ink); max-height: 140px; overflow: auto; }
.card .tags span.ai-pill { background: var(--gold-tint); color: #6d521a; display: inline-flex; align-items: center; gap: 2px; }
.card .tags span.ai-pill svg { width: 10px; height: 10px; }
.ai-panel { margin-bottom: 18px; }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; flex-wrap: wrap; }
.ai-head h2 { margin: 0; font-family: var(--head); font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--green); display: flex; align-items: center; gap: 6px; }
.ai-head h2 .ai-ic { width: 16px; height: 16px; }
.ai-stats { display: grid; grid-template-columns: 2.2fr repeat(4, 1fr); gap: 10px; padding: 10px 16px; }
.ai-stat { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.ai-stat .big { font-family: var(--head); font-size: 22px; font-weight: 700; color: var(--green); }
.ai-stat .big small { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.meter { height: 7px; background: #E6E1DA; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.meter i.hot { background: var(--danger); }
.ai-controls { display: flex; align-items: center; gap: 8px; padding: 6px 16px 12px; flex-wrap: wrap; }
.money-inp { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px; background: #fff; font-weight: 700; }
.money-inp input { width: 64px; border: 0; padding: 6px 2px; font: inherit; outline: none; }
.ai-block { border-top: 1px solid var(--line); padding: 12px 16px 14px; }
.ai-block .add-row { max-width: 420px; }
@media (max-width: 1100px) { .ai-stats { grid-template-columns: 1fr 1fr; } .ai-stat.wide { grid-column: 1 / -1; } }

/* ---------- People & partners: Photographer / creator, Sponsor / Vendor, Faculty ---------- */
.f-search { width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; outline: none; margin: 2px 0 6px; }
.f-search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(166,128,47,.13); }
.seg-sm { margin-bottom: 6px; }
.seg-sm button { padding: 3px 9px; font-size: 12px; }
.f-opt .sg { font-size: 10.5px; font-weight: 700; color: var(--gold); border: 1px dashed var(--gold-light); border-radius: 999px; padding: 0 5px; margin-left: auto; line-height: 15px; }
.f-opt .sg + .n { margin-left: 6px; }
.f-opt.f-none .lbl { color: var(--ink-soft); font-style: italic; }
.pp-type { font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--gold); background: var(--gold-tint); border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }
.pp-sg { color: var(--gold); }
.card .tags .pp-pill { background: var(--green); color: #fff; }
.card .tags .pp-pill.faculty { background: var(--sage); }
.card .tags .pp-pill.sg { background: #fff; color: var(--green); border: 1px dashed var(--gold-light); }
.pp-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 10px; background: #fff; }
.pp-box > label, .pp-box > .flabel { display: flex; align-items: center; gap: 6px; }
.pp-box > label svg, .pp-box > .flabel svg { width: 15px; height: 15px; flex: none; color: var(--gold); }
/* Headings that became <div class="flabel"> in PR #20: any icon in them stays label-sized and inline */
.flabel svg { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.pp-row { display: grid; grid-template-columns: 112px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--oat); }
.pp-row:first-of-type { border-top: 0; }
.pp-lbl { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); padding-top: 6px; }
.pp-val .tagbox:not(:empty) { margin-bottom: 6px; }
.pp-inp { padding: 6px 10px !important; font-size: 13px; }
.pp-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.pp-foot .hint { margin: 0 0 0 auto; }
.tag.pp-chip { padding: 4px 4px 4px 9px; }
.tag.pp-chip button { width: 20px; height: 20px; border: 0; background: none; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.tag.pp-chip button:hover { background: #fff; color: var(--green); }
.tag.pp-chip button.ok svg { width: 13px; height: 13px; }
.tag.pp-chip .q { color: var(--gold); font-weight: 800; }
.tag.pp-chip .n { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.tag.pp-suggested { background: #fff; border: 1px dashed var(--gold-light); }
.tag.pp-removing { text-decoration: line-through; opacity: .55; }
.tag.pp-adding { background: var(--green); color: #fff; }
.tag.pp-adding button { color: #fff; border: 0; background: none; cursor: pointer; }
.ac-wrap { position: relative; display: block; flex: 1; min-width: 180px; }
.ac-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; padding: 4px; }
.ac-list[hidden] { display: none; }
.ac-list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.ac-list button.on, .ac-list button:hover { background: var(--oat); }
.ac-list button .n { margin-left: auto; font-size: 11.5px; color: var(--ink-soft); }
.ac-list button.new { color: var(--gold); font-weight: 700; }
.ac-list button svg { width: 14px; height: 14px; }
.search { position: relative; }
.q-suggest { left: 120px; right: 20px; }
.q-suggest .pp-kind { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--sage-light); min-width: 132px; }
.pp-sec { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.pp-sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pp-sec-h b { font-family: var(--head); color: var(--green); }
.pp-sec-h .toggle { font-size: 12.5px; padding: 0; }
.pp-sec .tagbox { align-items: center; }
.pp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.pp-tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-family: var(--head); font-weight: 600; font-size: 13.5px; color: var(--ink-soft); border-bottom: 2px solid transparent; }
.pp-tabs button.on { color: var(--green); border-bottom-color: var(--gold); }
.pp-tabs .n { font-size: 11px; background: var(--oat); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.pp-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.pp-tools .inp { width: auto; min-width: 220px; }
.inp-sm { padding: 4px 8px !important; font-size: 12.5px; width: auto !important; }
#actionbar [data-bulk="selectmatching"] { color: var(--gold-light); }

.v-fallback { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; max-width: 520px; padding: 28px 32px; border-radius: 12px; background: rgba(0,0,0,.35); color: #F3F1EA; text-align: center; }
.v-fallback-title { margin: 0; font-size: 17px; font-weight: 600; }
.v-fallback-sub { margin: 0; font-size: 13px; color: #D7E0DA; }
.v-fallback-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }

/* Canva: upload progress cards (bottom left, above the page) and the Canva settings modal */
.canva-jobs { position: fixed; left: 20px; bottom: 92px; display: grid; gap: 8px; z-index: 90; width: 300px; max-width: calc(100vw - 40px); }
.canva-job { background: #fff; color: var(--ink, #1a3d31); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px; }
.canva-job .cj-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.canva-job .cj-h .icon-btn svg { width: 14px; height: 14px; }
.canva-job .cj-bar { height: 6px; background: #E8ECE9; border-radius: 4px; margin: 8px 0 6px; overflow: hidden; }
.canva-job .cj-bar span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.canva-job .cj-t { color: var(--ink-soft); margin-bottom: 4px; }
.cj-issues { margin: 0; padding-left: 18px; max-height: 50vh; overflow: auto; font-size: 13px; }
.cj-issues li { margin: 4px 0; }
.check-row { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; font-size: 13.5px; }
.canva-job.cj-ok { border-left: 4px solid var(--sage, #5b8a72); }
.canva-job.cj-ok .cj-bar span { background: var(--sage, #5b8a72); }
.canva-job .cj-link { font-weight: 700; font-size: 12.5px; color: var(--green); margin-left: 6px; }

/* Safety net: an inline icon SVG with no size rule of its own is text-sized, never "fill the box".
   :where() keeps specificity 0, so every component rule (.ai-ic, .pp-box .flabel svg, ...) still wins. */
:where(svg:not([width])) { width: 1.15em; height: 1.15em; flex: none; }

/* ==================================================================== Small screens (PR #27)
   Everything below is inside max-width media queries, so desktop (> 1100px) is unchanged.
   1100px and below: lightbox side panel = bottom sheet ("Details"), 44px tap targets.
   760px and below (phones): sidebar = slide-in drawer, filters = full-screen overlay, 2-column grid. */
.sb-head { display: contents; }
.sb-close, .sb-account { display: none; }
.r-filters { display: none; }
.nav-toggle, .f-close, .f-mfoot, .v-top .v-sheet-btn, .v-sheet-h, .nav-back { display: none; }

@media (max-width: 1100px) {
  html, body { overflow-x: hidden; }
  .app, .main { height: 100vh; height: 100dvh; }
  .search { min-width: 0; }
  .topbar > * { flex-shrink: 0; } .topbar > .search { flex-shrink: 1; }
  .topbar .spacer { display: none; } .topbar .avatar { margin-left: auto; }
  .topbar { padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left)); gap: 8px; }
  .results { padding: 14px max(16px, env(safe-area-inset-right)) calc(140px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

  /* Lightbox: the side panel becomes a scrollable bottom sheet over the photo */
  .v-side { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-height: 78vh; max-height: 78dvh; border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.35);
    transform: translateY(105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; padding-bottom: env(safe-area-inset-bottom); }
  .viewer.sheet-open .v-side { transform: none; visibility: visible; transition: transform .22s ease; }
  .v-top .v-sheet-btn { display: inline-flex; }
  .v-top .v-sheet-btn.on { background: var(--gold); }
  .v-sheet-h { display: flex; align-items: center; justify-content: center; position: relative; min-height: 44px; flex: none; border-bottom: 1px solid var(--line); }
  .v-sheet-h .grab { width: 40px; height: 5px; border-radius: 3px; background: #D9D3CA; }
  .v-sheet-h .icon-btn { position: absolute; right: 6px; top: 0; }
  .f-close { display: inline-grid; margin-left: 4px; }
  /* Labelled Filters button in the results toolbar (desktop has the panel always in view instead) */
  .r-tools .r-filters { display: inline-flex; border-color: var(--green); color: var(--green); }
  .r-filters .fcount { background: var(--gold); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; display: inline-grid; place-items: center; }
  .f-head h3 { margin-right: auto; }
  .tabs { overflow-x: auto; scrollbar-width: none; flex: none; }
  .tabs button { white-space: nowrap; flex: none; }
  .v-body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .v-top { padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); flex-wrap: wrap; z-index: 3; background: linear-gradient(rgba(17,22,20,.85), rgba(17,22,20,0)); }
  .v-stage { padding: 110px 12px calc(20px + env(safe-area-inset-bottom)); }
  .v-stage img, .v-stage video { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); }
  .v-nav { width: 44px; height: 56px; z-index: 2; }
  .v-prev { left: max(6px, env(safe-area-inset-left)); } .v-next { right: max(6px, env(safe-area-inset-right)); }

  /* Touch: at least 44px tap targets */
  .btn, .btn-sm, .icon-btn, .seg button, .actionbar button, .v-top button, .tabs button, .menu button, .f-group > button, .sb-item, .status-pick button,
  .f-head button, .f-more, .chips .link, .search select, .search .clear, .r-tools select, .r-tools .btn, .f-select, .inp, .field input, .field select,
  .tree-row, .toggle, .f-opt, .coll-list label, .linkbox input, .modal input[type=text], .modal select { min-height: 44px; }
  .icon-btn, .search .clear, .v-top button, .sb-title button, .avatar { min-width: 44px; }
  .avatar { width: 44px; height: 44px; }
  .sb-title button { min-height: 44px; }
  .tree-row .tw { width: 44px; min-height: 44px; align-self: stretch; }
  .search input, input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]), select { min-height: 44px; }
  .tbl a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  /* Remove/confirm buttons inside chips and tags: 44px hit area, same-size pill (negative margins) */
  .chip button, .tag button, .tag.pp-chip button { width: 44px; height: 44px; margin: -12px -8px -12px -6px; background-clip: content-box; padding: 12px; border-radius: 50%; flex: none; }
  .tag button, .tag.pp-chip button { background: none; }
  .tag.pp-chip button + button { margin-left: -16px; }
  .f-opt input, .toggle input { width: 20px; height: 20px; }
  .chips .link, .f-more, .f-head button { display: inline-flex; align-items: center; padding: 0 6px; }
  .menu { right: max(10px, env(safe-area-inset-right)); top: calc(60px + env(safe-area-inset-top)); }
  .menu button { display: flex; align-items: center; }
  /* No hover on touch: the card checkbox is always visible with a 44px hit area; card hover shortcuts live in the lightbox and the bulk bar */
  .card .cb { opacity: 1; top: 0; left: 0; width: 44px; height: 44px; border: 10px solid transparent; background-clip: padding-box; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.25); }
  .card .cb:checked, .card.sel .cb { border-color: transparent; box-shadow: none; background-clip: padding-box; }
  .card .hover-actions, .coll-card .hover-actions { display: none; }
  .badge.dup { left: 44px; }

  /* Bulk bar: one row that scrolls sideways, so every action stays reachable */
  .actionbar { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom)); transform: none; width: auto; max-width: none;
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding: 6px 8px 6px 14px; }
  .actionbar > * { flex: none; }

  /* Modals fit the screen and scroll */
  .modal-back { padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .modal { max-width: min(520px, 100%); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-width: 0; }
  .modal-b { overscroll-behavior: contain; min-width: 0; }
  .modal-f { flex-wrap: wrap; }
  .panel { overflow-x: auto; }
  .toasts { right: max(12px, env(safe-area-inset-right)); left: max(12px, env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); justify-items: end; }
  .canva-jobs { left: max(12px, env(safe-area-inset-left)); bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) {
  /* Sidebar: slide-in drawer from the hamburger */
  .nav-toggle { display: inline-grid; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: auto; width: min(84vw, 320px); height: 100vh; height: 100dvh; overflow-y: auto; z-index: 85;
    transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; box-shadow: 8px 0 30px rgba(0,0,0,.3);
    padding: 0 0 calc(env(safe-area-inset-bottom) + 72px) env(safe-area-inset-left); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav-back { position: fixed; inset: 0; z-index: 84; background: rgba(17,22,20,.55); touch-action: none; }
  .nav-open .nav-back { display: block; }
  /* Lock the page behind the open drawer */
  body.nav-open { overflow: hidden; overscroll-behavior: none; }
  body.nav-open .results, body.nav-open .filters { overflow: hidden; }
  /* Drawer header: brand + 44px close, clear of the status bar / notch */
  .sb-head { display: flex; align-items: flex-start; gap: 8px; position: sticky; top: 0; z-index: 2; background: var(--green);
    padding: max(16px, env(safe-area-inset-top)) 10px 10px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .sb-head .sb-logo { padding: 0; flex: 1; min-width: 0; }
  .sb-head .sb-logo img { max-width: 170px; }
  .sb-close { display: inline-grid; flex: none; width: 44px; height: 44px; color: #E9EFEA; margin-top: -4px; }
  .sb-close:hover { background: rgba(255,255,255,.08); color: #fff; }
  .sb-section { padding: 4px 12px; }
  .sb-title { padding: 16px 10px 6px; }
  .sb-item { padding: 10px 12px; min-height: 44px; }
  .sb-item:focus { outline: none; }
  .sb-item:focus-visible, .sb-close:focus-visible { outline: 2px solid var(--gold-light); outline-offset: -2px; }
  .sb-account { display: block; border-top: 1px solid rgba(255,255,255,.08); margin-top: 10px; }
  .sb-who { padding: 2px 12px 8px; color: #fff; }
  .sb-who-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
  .sb-who-email { font-weight: 400; font-size: 12.5px; color: var(--sage-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
  /* iOS Safari data detectors wrap emails/addresses in links; keep Account text undecorated */
  .sb-who a, .sb-who a[x-apple-data-detectors] { color: inherit !important; text-decoration: none !important; }
  .sb-foot { margin-top: 12px; }

  /* Top bar: compact search */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar > .search { order: 5; flex: 1 0 100%; max-width: none; }
  .search select { max-width: 112px; padding-left: 8px; }
  .search svg { margin: 0 2px 0 8px; }

  /* Filters: a full-screen overlay with Close and Apply */
  .filters { position: fixed; inset: 0; z-index: 75; width: 100%; height: 100vh; height: 100dvh; border: 0; box-shadow: none; padding: 0 0 0; display: flex; flex-direction: column; overflow-y: auto;
    padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .filters.closed { display: none; }
  .filters .f-head { position: sticky; top: 0; background: #fff; z-index: 2; border-bottom: 1px solid var(--line); gap: 8px; }
  .filters .f-head h3 { font-size: 14px; margin-right: auto; }
  .f-mfoot { display: flex; gap: 10px; position: sticky; bottom: 0; margin-top: auto; background: #fff; border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 2; }
  .f-mfoot .btn { flex: 1; min-height: 48px; font-size: 15px; }
  .filters-open .actionbar { display: none; }

  /* Grid: 2 columns */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .coll-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .r-head { align-items: stretch; }
  /* Same toolbar as desktop, on one row that scrolls sideways */
  .r-tools { margin-left: 0; width: calc(100% + 32px); margin-right: -16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-right: 16px; }
  .r-tools > * { flex: none; }
  .r-head { margin-bottom: 4px; }
  .r-title h1 { font-size: 19px; }
  .card .info { padding: 8px 9px 9px; }

  /* Lightbox on phones: icon-only actions, file name on its own line */
  .v-top .vt-l { display: none; }
  .v-top .vt-sp { display: none; }
  .v-top .nm { order: 10; flex: 1 0 100%; font-size: 13px; }
  .v-top .pos { margin-right: auto; }
  .v-top button { padding: 7px 10px; justify-content: center; }
  .v-side { max-height: 82vh; max-height: 82dvh; }
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .status-pick { grid-template-columns: repeat(2, 1fr); }
  .dup-group figure, .dup-group figure img { width: 140px; }
  .dup-group figure img { height: 100px; }
}

/* Share alerts: bell in the top bar + its panel, and the per-link Activity list */
.bell-btn { position: relative; }
.bell-btn .bell-n { position: absolute; top: -4px; right: -7px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px #fff; }
.alerts-panel { position: fixed; right: 16px; top: 56px; width: min(380px, calc(100vw - 24px)); max-height: min(520px, calc(100dvh - 80px)); overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 60; }
.alerts-panel .al-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.al-list, .act-list, .act-reqs { list-style: none; margin: 0; padding: 0; }
.al-item { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; font: inherit; font-size: 13.5px; min-height: 44px; border-bottom: 1px solid var(--line); }
.al-item:hover, .al-item:focus-visible { background: var(--oat, #F2EDE8); }
.al-item.unread { background: #FBF6EA; }
.al-item.unread .al-t { font-weight: 700; }
.al-ic { flex: none; width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; background: #EEF2EF; color: var(--green); }
.al-ic svg { width: 15px; height: 15px; }
.al-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.al-when { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.al-empty { padding: 18px 14px; color: var(--ink-soft); font-size: 13.5px; }
.act-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 18px 0 6px; }
.act-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.act-reqs li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; background: #FBF6EA; border-radius: 10px; margin-bottom: 6px; font-size: 13.5px; }
.act-note { margin-top: 4px; white-space: pre-line; color: var(--ink); }
.req-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 11px; font-weight: 800; }
@media (max-width: 760px) { .alerts-panel { right: 12px; left: 12px; width: auto; top: calc(56px + env(safe-area-inset-top)); } .act-reqs li { flex-direction: column; align-items: stretch; } }

/* Guest sign-in link on the login page, and guest (view and download only) mode: editing, sharing and admin controls
   are hidden here; the server refuses them anyway. */
.login-guest { margin-top: 28px; font-size: 13px; color: var(--sage-light); }
.login-guest a { color: #fff; font-weight: 700; }
.login-guest span { display: block; margin-top: 6px; font-size: 12px; }
body.is-guest [data-newcoll], body.is-guest #newColl, body.is-guest #pinSearch, body.is-guest [data-flag="showDnu"], body.is-guest [data-flag="showHidden"],
body.is-guest label:has(> [data-flag="showDnu"]), body.is-guest label:has(> [data-flag="showHidden"]), body.is-guest .ai-pill, body.is-guest .fav-on { display: none !important; }
