/* Meridian Photo Archive — styles
   Design language from nicokaiser/hugo-theme-gallery:
   light/dark auto (prefers-color-scheme), minimal chrome,
   centered hgroup titles, rounded 3:2 album cards, full-bleed gallery.
   v10: selection mode + modal z-index fix */

:root {
  color-scheme: light dark;
  --surface-1: #fff;
  --surface-2: #e5e5e5;
  --text-1: #0a0a0a;
  --text-2: #737373;
  --border: #bbb;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 1rem;
  --radius-sm: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #0a0a0a;
    --surface-2: #404040;
    --text-1: #fafafa;
    --text-2: #a3a3a3;
    --border: #606060;
    --danger: #f87171;
    --ok: #4ade80;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  }
}
/* manual theme override */
html[data-theme="light"] {
  color-scheme: light;
  --surface-1: #fff;
  --surface-2: #e5e5e5;
  --text-1: #0a0a0a;
  --text-2: #737373;
  --border: #bbb;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #0a0a0a;
  --surface-2: #404040;
  --text-1: #fafafa;
  --text-2: #a3a3a3;
  --border: #606060;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

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

html { height: 100%; scrollbar-gutter: stable; }

body {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  background-color: var(--surface-1);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Safe area insets for notched devices */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.hidden { display: none !important; }

/* ---------- header ---------- */
body > .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  margin-bottom: 2rem;
  width: 100%;
  min-height: 4rem;
}
@media (min-width: 640px) {
  body > .topbar { margin-bottom: 3rem; }
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: none;
  background: none;
  color: var(--text-1);
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding-right: 1rem;
  padding-left: 1rem;
  height: 3rem;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-square { padding: 0; width: 3rem; flex-shrink: 0; }
#menuToggle { margin-left: auto; } /* keep the menu button on the right even when the title is hidden */
.btn-square .icon-close { display: none; }
.btn-square[aria-expanded="true"] .icon-menu { display: none; }
.btn-square[aria-expanded="true"] .icon-close { display: block; }

/* secondary button (modals) */
.btn-ghost {
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  height: 2.5rem;
  padding-right: 0.875rem;
  padding-left: 0.875rem;
  color: var(--text-1);
}
.btn-primary {
  border: 1px solid var(--border);
  font-size: 0.9375rem;
  height: 2.5rem;
  padding-right: 0.875rem;
  padding-left: 0.875rem;
  background: var(--text-1);
  color: var(--surface-1);
}
.btn-primary:hover { opacity: 0.9; background: var(--text-1); }
.btn-primary:disabled { background: var(--surface-2); color: var(--text-2); }
.btn-sm { height: auto; padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* ---------- menu (right-side drawer with smooth transition) ---------- */
.menu-backdrop {
  position: fixed;
  inset: 0; /* anchored to all edges: always covers the visible viewport */
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.menu-backdrop.hidden { display: block !important; }
.menu-backdrop:not(.hidden) {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s ease;
}

body > menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0; /* top+bottom anchoring tracks the mobile URL bar precisely */
  z-index: 95;
  width: min(320px, 88vw);
  margin: 0;
  padding: calc(4.5rem + env(safe-area-inset-top)) 1.5rem calc(2.25rem + env(safe-area-inset-bottom));
  list-style: none;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  color: var(--text-2);
  font-weight: 600;
  font-size: 1.125rem;
  user-select: none;
  visibility: hidden;
  transform: translateX(105%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.32s;
}
body > menu.hidden { display: flex !important; }
body > menu:not(.hidden) {
  visibility: visible;
  transform: translateX(0);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
body > menu li { list-style: none; }
body > menu .menu-link {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  border: none;
  background: none;
  color: var(--text-2);
  font-weight: 600;
  font-size: 1.125rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s;
}
body > menu .menu-link:hover { color: var(--text-1); background: var(--surface-2); }
body > menu .menu-link.current { color: var(--text-1); }
body > menu .menu-search { 
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0 0.5rem; 
}
body > menu .search {
  flex: 1;
  min-width: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  outline: none;
  text-align: left;
}
body > menu .search::placeholder { color: var(--text-2); }
body > menu .search:focus { border-color: var(--text-2); }
body > menu .search-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
body > menu .search-filter-btn:hover { background: var(--surface-2); color: var(--text-1); }
body > menu .search-filter-btn.active { background: var(--surface-2); color: var(--ok); }
body > menu .menu-date-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0 0.5rem;
}
body > menu .menu-date-filter span { color: var(--text-2); font-size: 0.875rem; }
body > menu .date-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--surface-1);
  color: var(--text-1);
}
body > menu .date-input::-webkit-calendar-picker-indicator { filter: invert(0.5); }
html[data-theme="dark"] body > menu .date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body > menu .date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); }
}

/* ---------- main / hgroup ---------- */
body > main {
  flex-grow: 1;
  width: 100%;
}

.hgroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 0 auto 3rem;
  padding-right: 1.5rem;
  padding-left: 1.5rem;
  max-width: 1024px;
  text-align: center;
}
@media (min-width: 640px) {
  .hgroup { width: 83.3333%; margin-bottom: 4rem; }
}
.hgroup h1 {
  font-weight: 600;
  font-size: clamp(2rem, calc(1.667rem + 1.481vw), 3rem);
  line-height: clamp(2.25rem, calc(1.833rem + 1.852vw), 3.5rem);
  text-wrap: balance;
}
.hgroup h2 {
  font-weight: 600;
  font-size: clamp(1.5rem, calc(1.333rem + 0.741vw), 2rem);
  line-height: clamp(1.75rem, calc(1.5rem + 1.111vw), 2.5rem);
  text-wrap: balance;
}
.hgroup p {
  color: var(--text-2);
  font-size: 1.0625rem;
  line-height: 1.5556;
  text-wrap: balance;
}

/* ---------- album directory (home) ---------- */
.album-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 2rem 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
  padding-right: 1.5rem;
  padding-left: 1.5rem;
}
@media (min-width: 640px) {
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 3rem; }
}
@media (min-width: 1024px) {
  .album-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1440px) {
  .album-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.album-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.album-cover {
  aspect-ratio: 3 / 2;
  width: 100%;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.album-card:hover .album-cover { box-shadow: var(--shadow-lg); }
.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.album-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
}
.album-name { font-weight: 600; font-size: 1.125rem; line-height: 1.375; }
.album-lock { color: var(--text-2); font-size: 0.8125rem; }
.album-private-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-2);
  cursor: pointer;
}
.album-private-label input { width: auto; }
.album-desc {
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.4286;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.album-count { color: var(--text-2); font-size: 0.875rem; }
.album-ops { position: absolute; top: 0.75rem; right: 0.75rem; display: none; gap: 0.5rem; }
.album-card:hover .album-ops { display: flex; }
.album-ops .icon-btn {
  width: 2.5rem; height: 2.5rem; font-size: 0.9375rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.album-ops .icon-btn:hover { border-color: var(--text-2); }
.album-ops .icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.album-new {
  border: 1px dashed var(--border);
  background: transparent;
  border-radius: var(--radius);
  min-height: 150px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.album-new:hover { border-color: var(--text-2); color: var(--text-1); }

/* ---------- photo gallery (full-bleed justified grid) ---------- */
.gallery-wrap { padding-left: 0; padding-right: 0; }
.grid { position: relative; min-height: 100px; }
.photo-card {
  position: absolute;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
  animation: fadeUp 0.3s ease both;
}
.photo-card.selectable { cursor: pointer; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

/* Skeleton shimmer loading animation */
.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-1) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.pc-file-icon {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 2.5rem;
  background: var(--surface-2);
  color: var(--text-2);
  gap: 0.5rem;
}
.pc-file-icon .pc-name { font-size: 0.75rem; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- dates view ---------- */
.date-list { max-width: 768px; margin: 0 auto; padding: 0 1.5rem; }
.date-group { margin-bottom: 2.5rem; }
.date-year { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
.date-months { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.date-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.625rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 110px;
  text-align: center;
  color: var(--text-1);
}
.date-chip:hover { border-color: var(--text-2); }
.date-chip .dc-month { font-size: 1rem; font-weight: 500; }
.date-chip .dc-count { color: var(--text-2); font-size: 0.8125rem; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 5rem 1.5rem; color: var(--text-2); }
.empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.6; }
.empty .empty-text { font-size: 1rem; }

/* ---------- sentinel / loader ---------- */
.sentinel { height: 1px; }
.loading-ring {
  width: 34px; height: 34px;
  border: 2px solid var(--surface-2);
  border-top-color: var(--text-2);
  border-radius: 50%;
  margin: 3rem auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */
body > .footer {
  margin: 0 auto;
  padding: 2.5rem;
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.4286;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ---------- PhotoSwipe ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pswp__bg { background: #000; }
.pswp__button { background-color: transparent; border-radius: var(--radius-sm); margin: 0 2px; }
.pswp__button:hover { background-color: rgba(255, 255, 255, 0.15); }
.pswp__icn { color: #fff; }
.pswp__counter { color: #d4d4d4; font-size: 0.875rem; }
.pswp__top-bar { pointer-events: none; }
.pswp__top-bar > * { pointer-events: auto; }

/* Slideshow button active state */
.pswp__button--slideshow-active svg path {
  fill: #4ade80;
}
.pswp__button--slideshow-active {
  background-color: rgba(74, 222, 128, 0.15) !important;
}

.pswp__photo-info {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(560px, 86vw);
  text-align: left;
  pointer-events: none;
  transition: opacity 0.2s;
}
.pswp__photo-info.hidden {
  opacity: 0;
  pointer-events: none;
}
.pswp__photo-info .pi-name {
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.pswp__photo-info .pi-meta { color: #d4d4d4; font-size: 0.8125rem; margin-top: 3px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.pswp__photo-info .pi-desc { color: #d4d4d4; font-size: 0.8125rem; font-style: italic; margin-top: 3px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }

/* cover picker */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain; /* prevent scroll chaining to the page */
  -webkit-overflow-scrolling: touch;
  padding: 0.125rem;
}
@media (max-width: 560px) {
  .cover-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.cover-thumb {
  aspect-ratio: 3 / 2;
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.cover-thumb:hover { border-color: var(--text-2); }
.cover-thumb.current { border-color: var(--text-1); }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-thumb-icon { font-size: 1.5rem; opacity: 0.6; }
.cover-pager { display: flex; align-items: center; justify-content: center; gap: 0.75rem; }
.cover-page-info { color: var(--text-2); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100010; /* above PhotoSwipe (100000) */
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.15s ease;
}
.modal-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-wide { max-width: 620px; }
.modal-card h3 { font-size: 1.25rem; font-weight: 600; }
.modal-sub { color: var(--text-2); font-size: 0.8125rem; margin-top: -0.5rem; }
.modal-card input[type="text"], .modal-card input[type="password"], .modal-card select {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.modal-card input:focus, .modal-card select:focus { border-color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.625rem; margin-top: 0.25rem; }
.error { color: var(--danger); font-size: 0.8125rem; }

/* read-only mode banner (D1 daily quota exhausted) */
.read-only-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: #8a4b00;
  color: #fff;
  font-size: 0.8125rem;
  text-align: center;
  padding: 0.5rem 0.75rem;
  line-height: 1.35;
}
:root[data-theme="light"] .read-only-bar { background: #ffe8cc; color: #7a3d00; }

/* image editor (rotate / crop) */
.edit-card { max-width: 780px; }
.edit-stage {
  position: relative;
  align-self: center;
  max-width: 100%;
  background: #0b0d12;
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  line-height: 0;
}
#editCanvas { display: block; max-width: 100%; height: auto; }
.edit-stage.loading { display: none; }
.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
  touch-action: none;
}
.crop-box.hidden { display: none; }
.crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  touch-action: none;
}
.crop-handle[data-handle="nw"] { left: 2px; top: 2px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { right: 2px; top: 2px; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { left: 2px; bottom: 2px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { right: 2px; bottom: 2px; cursor: nwse-resize; }
.edit-hint { color: var(--text-2); font-size: 0.75rem; text-align: center; }
.edit-toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.edit-size { margin-left: auto; color: var(--text-2); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.edit-card .btn:disabled { opacity: 0.45; cursor: not-allowed; }


/* dropzone */
.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.875rem 1rem;
  text-align: center;
  color: var(--text-2);
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
}
.dropzone.dragover { border-color: var(--text-1); background: var(--surface-2); }
.dz-icon { font-size: 2.375rem; opacity: 0.7; }
.dz-btn { display: inline-block; margin-top: 0.125rem; }
.dz-hint { font-size: 0.75rem; opacity: 0.7; }

.upload-row { display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap; }
.upload-label { font-size: 0.875rem; color: var(--text-2); }
.upload-row select { width: auto; flex: 1; min-width: 160px; }

.upload-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 220px; overflow-y: auto; }
.upload-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.upload-item img.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 0.375rem; background: var(--surface-2); flex-shrink: 0; }
.upload-item .u-name { flex: 1; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .u-size { color: var(--text-2); font-size: 0.75rem; flex-shrink: 0; }
.upload-item .u-status { font-size: 0.75rem; flex-shrink: 0; }
.upload-item .u-status.ok { color: var(--ok); }
.upload-item .u-status.err { color: var(--danger); }
.upload-item .u-remove { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 0.9375rem; flex-shrink: 0; }
.upload-item .u-remove:hover { color: var(--danger); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--text-1); transition: width 0.2s; }
.upload-status { font-size: 0.8125rem; color: var(--text-2); min-height: 18px; }

/* album manage list */
.album-manage-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 260px; overflow-y: auto; }
.album-manage-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}
.album-manage-item .am-name { flex: 1; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-manage-item .am-count { color: var(--text-2); font-size: 0.75rem; }
.album-manage-item .icon-btn {
  width: 2.25rem; height: 2.25rem; font-size: 0.8125rem;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-1); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.album-manage-item .icon-btn:hover { border-color: var(--text-2); }
.album-manage-item .icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.album-create { display: flex; gap: 0.625rem; align-items: flex-end; }
.album-create-fields { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }

/* toasts */
.toasts {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100020;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 999px;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 90vw;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- photo selection (batch move) ---------- */
.photo-card .card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  z-index: 3;
}
.photo-card.selectable .card-check { display: flex; }
.photo-card.selected .card-check {
  display: flex;
  background: #fff;
  border-color: #fff;
  color: #0a0a0a;
}
.photo-card.selected { outline: 3px solid #fff; outline-offset: -3px; }

.select-mode-btn {
  border: 1px solid var(--border);
  background: none;
  color: var(--text-1);
  border-radius: 999px;
  padding: 0.5rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.select-mode-btn:hover { border-color: var(--text-2); }

.select-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-lg);
}
.select-bar .select-count { font-size: 0.9375rem; color: var(--text-2); min-width: 4.5rem; text-align: center; white-space: nowrap; }
.select-bar .btn-ghost.danger { color: var(--danger); }
.select-bar .btn-ghost.danger:hover { border-color: var(--danger); background: transparent; }
@media (max-width: 720px) {
  .select-bar { bottom: 1rem; gap: 0.5rem; padding: 0.5rem; }
  .select-bar .select-count { min-width: 3.5rem; font-size: 0.8125rem; }
}

/* Quick preview (long-press on mobile) */
.quick-preview {
  position: fixed;
  z-index: 100030;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  max-width: min(320px, 90vw);
  animation: fadeIn 0.15s ease;
  pointer-events: none;
}
.quick-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.quick-preview .qp-info {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-2);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Offline indicator */
body.is-offline::before {
  content: "●";
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  color: var(--danger);
  font-size: 0.75rem;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  body > .topbar { padding: 0.375rem 0.5rem; margin-bottom: 1.5rem; }
  body > .topbar .btn { font-size: 1.125rem; height: 2.75rem; }
  body > .topbar .btn-square { width: 2.75rem; }
  .pswp__photo-info { left: 16px; bottom: 14px; }
}

/* 手机端：菜单改为右上角浮动卡片（桌面侧边抽屉不变） */
@media (max-width: 720px) {
  body > menu {
    top: max(0.5rem, env(safe-area-inset-top));
    right: 0.5rem;
    bottom: auto;
    width: min(280px, calc(100vw - 1rem));
    max-height: calc(100dvh - 1rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: 0;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.0625rem;
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.97);
    transform-origin: top right;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s,
                visibility 0s linear 0.22s;
  }
  body > menu:not(.hidden) {
    opacity: 1;
    transform: none;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s;
  }
  body > menu .menu-search { padding: 0.25rem 0 0.5rem; }
}
