/* Design tokens and components follow /home/www/pics (public/admin/admin.css)
   so the two apps read as the same product. */
:root {
  --bg: #f4f4f2;
  --card: #fff;
  --text: #1c1c1e;
  --muted: #7a7a80;
  --line: #e5e4df;
  --ink: #1c1c1e;
  --accent: #2f6feb;
  --danger: #c0392b;
  --field-line: #d9d7d0;
  --hover: #f0efec;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin: 0; }
.err[hidden] { display: none; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .06);
}
.login-logo { width: 64px; height: 64px; align-self: center; }
.login-card h1 { margin: 0; font-size: 24px; text-align: center; }
.login-lead { margin: -4px 0 6px; text-align: center; }
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
}
.login-card input:focus { outline: none; border-color: var(--ink); }
.login-card .btn { margin-top: 4px; width: 100%; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; color: var(--muted); }
.login-foot { text-align: center; margin: 6px 0 0; }

/* topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  max-width: 980px;
  margin: 0 auto;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.brand-logo { height: 48px; width: 48px; display: block; flex: 0 0 auto; }
.brand-name { font-size: 16px; font-weight: 600; }

/* user menu */
.usermenu { position: relative; flex: 0 0 auto; }
.usermenu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  max-width: 220px;
}
.usermenu-btn:hover { background: var(--hover); }
.usermenu-btn #user-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 11px; }
.usermenu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
  padding: 6px;
  z-index: 30;
}
.usermenu-panel[hidden] { display: none; }
.menu-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-name { font-size: 14px; font-weight: 600; }
.menu-mail { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.menu-item:hover { background: var(--hover); }

/* accounts */
.section-title { margin: 22px 0 12px; font-size: 18px; }
.accounts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  flex-wrap: wrap;
}
.account-row .who { font-size: 14px; }
.account-row .who small { display: block; color: var(--muted); font-size: 12px; }
.account-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #e8eefc; color: #274690; margin-left: 8px; vertical-align: middle; }
.badge.you { background: #e7f6ec; color: #1c7a3f; }
.inline select { padding: 9px 11px; border: 1px solid var(--field-line); border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); }

/* folder sharing */
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.modal-card-lg { width: min(520px, 94vw); max-height: 88vh; overflow-y: auto; }
.people { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 8px; }
.people label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.badge.open { background: #e7f6ec; color: #1c7a3f; }
.badge.locked { background: #fdf1dd; color: #8a5a00; }
.badge.shared { background: #e8eefc; color: #274690; }
.folder-users { font-size: 13px; color: var(--muted); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin: 22px 0; }
.card h2 { margin: 0 0 14px; font-size: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input { padding: 9px 11px; border: 1px solid var(--field-line); border-radius: 9px; font-size: 14px; font-family: inherit; }
.inline input:focus { outline: none; border-color: var(--ink); }

.search { padding: 8px 12px; border: 1px solid var(--field-line); border-radius: 9px; font-size: 14px; min-width: 180px; font-family: inherit; }
.search:focus { outline: none; border-color: var(--ink); }

/* buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  color: var(--ink);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-danger { color: var(--danger); border-color: #e6c4bf; }
.btn-danger:hover:not(:disabled) { background: #fbeae7; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* breadcrumbs */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; }
.crumb { background: none; border: 0; padding: 2px 4px; font: inherit; color: var(--accent); cursor: pointer; }
.crumb:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.crumb-current { font-weight: 600; padding: 2px 4px; background: none; border: 0; font-family: inherit; font-size: inherit; color: var(--ink); }

/* upload */
.dropzone {
  border: 1px dashed var(--field-line);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fafaf8;
}
.dropzone.hot { border-color: var(--accent); background: #eef2fd; }
.dropzone-text { font-size: 14px; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.progress-track { height: 6px; background: #eee; border-radius: 6px; overflow: hidden; margin-top: 12px; }
.progress-track[hidden] { display: none; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .15s linear; }

/* entry rows */
.entries { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.entry-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.entry-icon { flex: 0 0 auto; color: var(--muted); display: grid; place-items: center; }
.entry-icon svg { width: 22px; height: 22px; display: block; }
.entry-dir .entry-icon { color: var(--accent); }
.entry-name { font-weight: 600; font-size: 15px; background: none; border: 0; padding: 0; font-family: inherit; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
button.entry-name { cursor: pointer; }
a.entry-name { text-decoration: none; }
button.entry-name:hover, a.entry-name:hover { color: var(--accent); text-decoration: underline; }
.entry-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.entry-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 40px 16px; }
.empty-title { font-size: 17px; font-weight: 600; margin: 0 0 6px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border-radius: 16px; padding: 26px; width: min(400px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-card h2 { margin: 0 0 16px; font-size: 20px; }
.modal-card input { padding: 10px 12px; border: 1px solid var(--field-line); border-radius: 9px; font-size: 14px; width: 100%; font-family: inherit; }
.modal-card input:focus { outline: none; border-color: var(--ink); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }

/* gallery grid and viewbar, lifted from /home/www/pics (gallery/style.css) */
.viewbar { display: flex; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.viewbar[hidden] { display: none; }
.viewbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 34px;
  border: 1px solid var(--field-line);
  background: #fff;
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
}
.viewbtn svg { width: 17px; height: 17px; display: block; }
.viewbtn:hover { color: var(--ink); }
.viewbtn.active { color: var(--ink); border-color: var(--ink); background: var(--hover); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.gallery[hidden] { display: none; }
.tile {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  background: #eceae4;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: box-shadow .2s ease, transform .2s ease;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s ease; }
.tile img.loaded { opacity: 1; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .10); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .62));
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
.tile-caption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-del {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font: inherit;
  font-size: 12px;
  padding: 4px 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
}
.tile:hover .tile-del, .tile-del:focus-visible { opacity: 1; }
.tile-del:hover { background: var(--danger); }
@media (hover: none) { .tile-del { opacity: 1; } }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(16, 16, 18, .96); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 12px; }
.lightbox[hidden] { display: none; }
.lb-figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.lb-stage { display: flex; align-items: center; justify-content: center; max-width: 92vw; max-height: 78vh; overflow: hidden; touch-action: none; }
.lb-frame { position: relative; display: inline-block; transform: translate(0, 0) scale(1); transform-origin: center center; transition: transform .12s ease-out; will-change: transform; }
.lb-frame img { display: block; max-width: 92vw; max-height: 78vh; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); user-select: none; -webkit-user-drag: none; }
.lb-stage.zoomed { cursor: grab; }
.lb-stage.zoomed .lb-frame { transition: none; }
.lb-stage.panning { cursor: grabbing; }
.lb-bar { display: flex; align-items: center; gap: 18px; color: rgba(255, 255, 255, .75); font-size: 14px; flex-wrap: wrap; justify-content: center; }
.lb-count { color: rgba(255, 255, 255, .5); }
.lb-tools { display: flex; gap: 8px; }
.tool {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.tool:hover { background: rgba(255, 255, 255, .18); }
.lb-close { position: absolute; top: 16px; right: 20px; background: none; border: 0; color: #fff; font-size: 40px; line-height: 1; cursor: pointer; opacity: .8; }
.lb-close:hover { opacity: 1; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-nav:hover { background: rgba(255, 255, 255, .2); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

@media (max-width: 600px) {
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .lb-nav { width: 44px; height: 44px; }
  .lb-frame img { max-height: 70vh; }
}

/* toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1e;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  .brand-logo { height: 40px; width: 40px; }
  .entry-meta { white-space: normal; }
}
