/* ============================================================
   FotoNAS — professional dark UI (OLED), no gradients, SVG icons
   Type: Fira Sans (UI) + Fira Code (data/mono)
   ============================================================ */
:root {
  /* surfaces */
  --bg: #0a0c0f;
  --surface: #111419;
  --surface-2: #161a21;
  --surface-3: #1b212a;
  --hover: rgba(255, 255, 255, .045);
  --border: #232a33;
  --border-strong: #313a45;

  /* text */
  --text: #e9edf2;
  --text-muted: #a7b0bd;
  --text-faint: #6f7886;

  /* brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;
  --accent: #4d8bff;
  --primary-soft: rgba(37, 99, 235, .14);
  --primary-ring: rgba(45, 110, 240, .45);

  /* semantic */
  --success: #10b981;
  --warning: #d9a23b;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .12);

  /* shape */
  --r-sm: 7px;
  --r: 9px;
  --r-lg: 13px;
  --shadow: 0 16px 40px rgba(0, 0, 0, .55);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);

  --sans: 'Fira Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: 'Fira Code', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; }
::selection { background: rgba(37, 99, 235, .35); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #283039; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #364250; background-clip: content-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============ buttons ============ */
.btn {
  appearance: none; cursor: pointer; font-family: inherit;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: 9px 14px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { background: #20262f; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); border-color: rgba(229, 72, 77, .35); background: var(--danger-soft); }
.btn.danger:hover { background: rgba(229, 72, 77, .2); border-color: var(--danger); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.icon { padding: 8px; border-radius: var(--r-sm); }
.btn.icon.ghost { color: var(--text-muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* ============ inputs ============ */
input, select {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
label { display: block; font-size: 12.5px; color: var(--text-muted); margin: 14px 0 6px; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 5px; background: var(--primary-soft); border: 1px solid rgba(37,99,235,.3); color: var(--accent); font-weight: 600; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border-strong); color: var(--text-muted); font-weight: 500; }
.pill.valid { color: var(--success); border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.1); }
.pill.used { color: var(--text-faint); }
.pill.expired { color: var(--danger); border-color: rgba(229,72,77,.35); }

/* ============ app layout ============ */
.layout { display: grid; grid-template-columns: 272px 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; letter-spacing: -.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--primary); display: grid; place-items: center; flex: 0 0 28px; }
.brand .logo svg { width: 16px; height: 16px; color: #fff; }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 6px; }
.side-head span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-muted); cursor: pointer; font-weight: 500; font-size: 14px; user-select: none;
  transition: background .13s, color .13s; position: relative;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item.drop { box-shadow: inset 0 0 0 1.5px var(--primary); background: var(--primary-soft); }

.tree { display: flex; flex-direction: column; gap: 1px; }
.folder-row { display: flex; align-items: center; }
.folder-row .twist { width: 18px; height: 22px; display: grid; place-items: center; color: var(--text-faint); cursor: pointer; flex: 0 0 18px; }
.folder-row .twist svg { width: 12px; height: 12px; transition: transform .15s; }
.folder-row .twist.open svg { transform: rotate(90deg); }
.folder-row .twist.leaf { visibility: hidden; }
.folder-row .nav-item { flex: 1; min-width: 0; }
.folder-row .nav-item span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .nav-item > svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.folder-row .facts { display: none; margin-left: auto; gap: 1px; }
.folder-row:hover .facts { display: flex; }
.folder-row:hover .count { display: none; }
.fact { appearance: none; background: transparent; border: 0; color: var(--text-faint); cursor: pointer; padding: 3px; border-radius: 5px; display: grid; place-items: center; }
.fact:hover { background: var(--hover); color: var(--text); }
.fact svg { width: 14px; height: 14px; }

.sidebar .spacer { flex: 1; min-height: 10px; }
.storage { padding: 12px; margin-top: 8px; }
.storage .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.storage .bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 8px 0 0; }
.storage .bar > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--accent); flex: 0 0 32px; }
.user-chip .meta { line-height: 1.25; min-width: 0; flex: 1; }
.user-chip .meta b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta small { color: var(--text-faint); font-size: 12px; }

/* ============ main ============ */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: rgba(10,12,15,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; min-width: 0; flex-wrap: wrap; }
.crumbs .sep { color: var(--text-faint); font-weight: 400; }
.crumbs a { color: var(--text-muted); cursor: pointer; } .crumbs a:hover { color: var(--text); }
.crumbs .cur { color: var(--text); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.scrim { display: none; } /* only a grid sibling on mobile; never occupy a desktop column */
.content { padding: 20px 24px 120px; }

/* ============ gallery grid ============ */
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--surface-2); cursor: pointer; border: 1px solid var(--border); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.tile:hover img { transform: scale(1.05); }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.5), transparent 45%); opacity: 0; transition: opacity .2s; }
.tile:hover::after { opacity: 1; }
.tile .owner-tag { position: absolute; left: 8px; bottom: 8px; z-index: 2; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; opacity: 0; transition: opacity .2s; }
.tile:hover .owner-tag { opacity: 1; }
.tile .check { position: absolute; top: 8px; left: 8px; z-index: 3; width: 22px; height: 22px; border-radius: 6px; border: 2px solid rgba(255,255,255,.85); background: rgba(0,0,0,.4); display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .15s; }
.tile:hover .check { opacity: 1; }
.tile .check svg { width: 13px; height: 13px; color: #fff; opacity: 0; }
.tile.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.tile.sel .check { opacity: 1; background: var(--primary); border-color: var(--primary); }
.tile.sel .check svg { opacity: 1; }
.tile.sel img { transform: scale(.9); }

.folder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 10px; margin-bottom: 24px; }
.fcard { display: flex; align-items: center; gap: 12px; padding: 13px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.fcard:hover { border-color: var(--border-strong); background: var(--surface-2); }
.fcard.drop { box-shadow: inset 0 0 0 1.5px var(--primary); }
.fcard .fico { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--accent); flex: 0 0 36px; }
.fcard .fico svg { width: 19px; height: 19px; }
.fcard .fmeta { min-width: 0; }
.fcard .fmeta b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard .fmeta small { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.fcard .fdel { margin-left: auto; }

.empty { text-align: center; color: var(--text-muted); padding: 72px 20px; }
.empty svg { width: 46px; height: 46px; color: var(--text-faint); margin-bottom: 14px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty p { margin: 0; font-size: 14px; }

/* ============ selection bar ============ */
.selbar {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(140%); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 9px 9px 9px 16px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.selbar.show { transform: translateX(-50%) translateY(0); }
.selbar b { font-size: 13.5px; margin-right: 4px; font-variant-numeric: tabular-nums; }

/* ============ lightbox ============ */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(5,6,8,.95); display: none; align-items: center; justify-content: center; }
.lightbox.open { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.lightbox img { max-width: 90vw; max-height: 82vh; border-radius: var(--r); box-shadow: var(--shadow); }
.lb-top { position: absolute; top: 0; left: 0; right: 0; padding: 16px 20px; display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, rgba(0,0,0,.55), transparent); }
.lb-meta { color: #eef1f5; font-size: 13.5px; } .lb-meta small { display: block; color: #aab3c0; font-size: 12.5px; }
.lb-top .spacer { flex: 1; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.07); border: 1px solid var(--border-strong); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s; }
.lb-nav:hover { background: rgba(255,255,255,.16); }
.lb-nav svg { width: 22px; height: 22px; }
.lb-nav.prev { left: 18px; } .lb-nav.next { right: 18px; }

/* ============ modal ============ */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; padding: 20px; }
.overlay.open { display: flex; animation: fade .15s ease; }
.modal { width: 100%; max-width: 430px; padding: 22px; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p.sub { margin: 0 0 14px; color: var(--text-muted); font-size: 13.5px; }
.modal .dlg-input { margin-top: 6px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.warn-list { max-height: 240px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 12px; }
.warn-list div { font-size: 13px; color: var(--text-muted); padding: 7px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.warn-list div:last-child { border-bottom: 0; }
.warn-list .ext { color: var(--warning); font-weight: 600; font-family: var(--mono); font-size: 12px; }

/* ============ drag overlay ============ */
.dragmask { position: fixed; inset: 12px; z-index: 80; border: 2px dashed var(--primary); border-radius: var(--r-lg); background: rgba(37,99,235,.08); display: none; align-items: center; justify-content: center; pointer-events: none; }
.dragmask.show { display: flex; animation: fade .12s ease; }
.dragmask .inner { text-align: center; color: var(--text); }
.dragmask .inner svg { width: 52px; height: 52px; color: var(--accent); }
.dragmask .inner h2 { margin: 12px 0 4px; font-size: 20px; }
.dragmask .inner p { color: var(--text-muted); margin: 0; }

/* ============ upload tray ============ */
.uploadtray { position: fixed; bottom: 20px; right: 20px; width: 320px; z-index: 45; padding: 15px; display: none; }
.uploadtray.show { display: block; animation: slideup .25s ease; }
@keyframes slideup { from { transform: translateY(16px); opacity: 0; } }
.uploadtray .ut-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.uploadtray .ut-head b { font-size: 13.5px; font-weight: 600; }
.uploadtray .ut-head span { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.uploadtray .bar { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.uploadtray .bar > div { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .2s; }
.uploadtray small { color: var(--text-faint); display: block; margin-top: 8px; font-size: 12.5px; }

/* ============ toast ============ */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 16px; border-radius: var(--r); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; font-size: 13.5px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(229,72,77,.5); }

/* ============ auth pages ============ */
.page-center { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; padding: 30px; }
.auth-card .brand { padding: 0 0 8px; }
.auth-card h1 { margin: 6px 0 4px; font-size: 21px; }
.auth-card p.sub { margin: 0 0 12px; color: var(--text-muted); font-size: 13.5px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 11px; }
.msg { margin-top: 14px; font-size: 13.5px; padding: 10px 12px; border-radius: var(--r-sm); display: none; }
.msg.err { display: block; color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(229,72,77,.3); }
.msg.ok { display: block; color: var(--success); background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); }

/* ============ admin ============ */
.wrap { max-width: 1140px; margin: 0 auto; padding: 24px 22px 80px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 18px; }
.stat .n { font-size: 27px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.section { padding: 22px; margin-bottom: 20px; }
.section h3 { margin: 0 0 16px; font-size: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 150px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
td { font-variant-numeric: tabular-nums; }
th { color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--hover); }
.invite-link { display: flex; gap: 8px; }
.invite-link input { font-family: var(--mono); font-size: 12px; }

/* ============ responsive ============ */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 272px; z-index: 90; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 85; display: none; }
  .scrim.show { display: block; }
  .content { padding: 16px 14px 120px; }
  .topbar { padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============ search ============ */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 0 10px; max-width: 230px; }
.search svg { width: 16px; height: 16px; color: var(--text-faint); flex: 0 0 16px; }
.search input { border: 0; background: transparent; padding: 8px 0; }
.search input:focus { box-shadow: none; }

/* ============ timeline ============ */
.tl-head { font-size: 15px; font-weight: 600; color: var(--text); margin: 20px 2px 12px; text-transform: capitalize; }
.tl-head:first-child { margin-top: 0; }
#timeline .grid { margin-bottom: 6px; }

/* ============ favorite badge ============ */
.fav-badge { position: absolute; top: 8px; right: 8px; z-index: 2; color: var(--danger); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.fav-badge svg { width: 19px; height: 19px; }

/* ============ map ============ */
#map { height: calc(100dvh - 132px); border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); }
.leaflet-container { background: #0e1116; font-family: var(--sans); }
.photo-marker img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.55); }

/* ============ lightbox stage / zoom / buttons ============ */
.lb-stage { max-width: 92vw; max-height: 84vh; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.lb-stage img { max-width: 92vw; max-height: 84vh; border-radius: var(--r); transition: transform .08s linear; will-change: transform; user-select: none; -webkit-user-drag: none; }
.lb-btn { color: #fff; }
.lb-btn svg { width: 19px; height: 19px; }
.lb-btn.on svg { stroke: var(--danger); fill: var(--danger); }

/* ============ exif panel ============ */
.lb-exif { position: absolute; top: 0; right: 0; width: 300px; max-width: 85vw; height: 100%; background: var(--surface); border-left: 1px solid var(--border); padding: 66px 18px 18px; overflow-y: auto; transform: translateX(100%); transition: transform .2s ease; z-index: 2; }
.lightbox.show-exif .lb-exif { transform: translateX(0); }
.lb-exif h4 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.lb-exif div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.lb-exif div span { color: var(--text-muted); } .lb-exif div b { text-align: right; word-break: break-word; }
.lb-exif .exif-map { display: inline-block; margin-top: 14px; font-weight: 600; }

/* ============ share QR ============ */
.share-qr { display: flex; justify-content: center; margin: 16px 0; }
.share-qr img { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }

/* ============ touch & PWA ============ */
* { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
.btn, .nav-item, .tile, .bn, .fact, .lb-nav, .lb-btn, .fcard, a { touch-action: manipulation; }
.bottomnav { display: none; }

@media (max-width: 860px) {
  input, select { font-size: 16px; }              /* prevents iOS zoom-on-focus */
  .hide-mobile { display: none !important; }
  .search { max-width: 150px; }
  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .sidebar { padding-top: calc(16px + env(safe-area-inset-top)); }
  .content { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 6px; }
  #map { height: calc(100dvh - 196px); }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    justify-content: space-around; align-items: center;
    background: rgba(17,20,25,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav .bn { appearance: none; border: 0; background: transparent; color: var(--text-faint); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; padding: 6px 8px; min-width: 54px; border-radius: 10px; font-family: inherit; }
  .bottomnav .bn svg { width: 22px; height: 22px; }
  .bottomnav .bn.active { color: var(--accent); }
  .bottomnav .bn-up { background: var(--primary); color: #fff; width: 52px; height: 52px; border-radius: 50%; margin-top: -20px; box-shadow: 0 6px 16px rgba(37,99,235,.45); min-width: 0; }
  .bottomnav .bn-up svg { width: 26px; height: 26px; }

  .selbar { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .uploadtray { bottom: calc(82px + env(safe-area-inset-bottom)); left: 12px; right: 12px; width: auto; }

  .lb-top { padding: calc(10px + env(safe-area-inset-top)) 8px 10px; gap: 2px; }
  .lb-top .lb-meta { display: none; }   /* keep room for the action buttons */
  .lb-btn { padding: 9px; }
  .lb-nav { width: 40px; height: 40px; }
  .lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
}

/* touch devices: surface controls that are hover-only on desktop */
@media (hover: none) {
  .tile .check { opacity: .5; }
  .tile.sel .check { opacity: 1; }
  .tile .owner-tag { opacity: 1; }
  .folder-row .facts { display: flex; }
  .folder-row:hover .count, .folder-row .count { display: none; }
}
