/* ===========================================================================
   N5 Galleries · mobile app section (Pages/Mobile)
   Self-contained — depends only on theme.css tokens, not site.css. Big tap
   targets, no hover-only affordances (nothing here should require a mouse).
   =========================================================================== */

.m-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.m-header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  margin: -8px 0 -8px -8px;
  border-radius: var(--radius-pill);
  color: var(--text);
  flex-shrink: 0;
}
.m-header-back:active { background: var(--surface-alt); }
.m-header-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-header-action {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font: 600 14px var(--font-ui);
}
.m-header-action:active { background: var(--accent-hover); }
.m-header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}
.m-header-icon-btn:active { background: var(--surface-alt); }
.m-header-icon-btn[hidden] { display: none; }

.m-main {
  padding: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

/* ---- Install banner ---- */
.m-install-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
/* Without this, the [hidden] attribute does nothing here — an author rule setting
   `display` on this class otherwise wins over the browser's own `[hidden]{display:none}`
   default regardless of specificity, since author styles take precedence over the
   user-agent stylesheet. Toggling `.hidden` via JS (banner.hidden = true) would silently
   leave the banner visible without this explicit override. */
.m-install-banner[hidden] { display: none; }
.m-install-banner p { margin: 0; font-size: 13px; color: var(--text-secondary); flex: 1; }
.m-install-banner button {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font: 600 13px var(--font-ui);
}
.m-install-banner .m-dismiss {
  background: none;
  color: var(--text-muted);
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}

/* ---- Gallery list (Index) ---- */
.m-gallery-list { display: flex; flex-direction: column; gap: 10px; }
.m-gallery-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.m-gallery-row:active { background: var(--surface-alt); }
/* The tappable part of the card that opens the gallery (everything except the preview icon). */
.m-gallery-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
/* Preview (eye) icon on the empty right side of the card — a 44px touch target. */
.m-gallery-view {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}
.m-gallery-view:active { background: var(--surface-alt); }
.m-gallery-thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  object-fit: cover;
  flex-shrink: 0;
}
.m-gallery-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}
.m-gallery-info { flex: 1; min-width: 0; }
.m-gallery-name {
  font: 600 15px var(--font-ui);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-gallery-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.m-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}
.m-empty .m-empty-icon { font-size: 32px; margin-bottom: 8px; }

/* ---- Section cards (Gallery detail) ---- */
.m-section-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.m-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.m-section-name { font: 600 15px var(--font-ui); }
.m-section-count { font-size: 12px; color: var(--text-muted); }

.m-thumb-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.m-thumb-strip img {
  width: 64px; height: 64px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-alt);
}
.m-thumb-more {
  width: 64px; height: 64px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font: 600 12px var(--font-ui);
}

.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: 600 14px var(--font-ui);
}
.m-btn:active { background: var(--surface-alt); }
.m-btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.m-btn-primary:active { background: var(--accent-hover); }
.m-btn[disabled] { opacity: .5; }

.m-add-section-btn { margin-top: 4px; }

/* ---- Share panel ---- */
.m-share-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.m-share-card h3 {
  font: 600 14px var(--font-ui);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
}
.m-share-link-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.m-share-link-row:first-of-type { border-top: none; padding-top: 0; }
.m-share-url {
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}
.m-share-expiry {
  font-size: 12px;
  color: var(--text-muted);
}
.m-share-actions { display: flex; gap: 8px; }
.m-share-actions .m-btn { width: auto; flex: 1; padding: 9px 10px; font-size: 13px; }

/* ---- Toasts ---- */
.m-toast-host {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  padding: 0 16px max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
  z-index: 100;
}
.m-toast {
  background: var(--text);
  color: var(--text-on-accent);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.m-toast.m-toast-in { opacity: 1; transform: translateY(0); }
.m-toast.m-toast-error { background: var(--danger); }

/* Hidden native file input — triggered via a visible .m-btn label. */
.m-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ---- Public install page (/install) ---- */
.m-install { text-align: center; padding-top: 28px; }
.m-install-hero img { display: block; margin: 0 auto 12px; border-radius: 16px; }
.m-install-hero h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 8px;
}
.m-install-hero p { margin: 0 auto 28px; color: var(--text-secondary); max-width: 320px; font-size: 14px; line-height: 1.5; }
.m-install-state { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.m-install-state[hidden] { display: none; }
.m-install-big { padding: 16px 18px; font-size: 16px; max-width: 360px; text-decoration: none; }
.m-install-lead { margin: 0; font-size: 15px; font-weight: 500; }
.m-install-note { margin: 0; font-size: 13px; color: var(--text-secondary); max-width: 320px; line-height: 1.5; }
.m-install-steps {
  text-align: left;
  margin: 0;
  padding-left: 22px;
  max-width: 340px;
  font-size: 15px;
  line-height: 1.55;
}
.m-install-steps li { margin-bottom: 10px; }
.m-install-inline-icon { vertical-align: -3px; }
.m-install-qr { border: 1px solid var(--line); padding: 8px; background: #fff; border-radius: var(--radius-sm); }
.m-install-foot { margin-top: 32px; font-size: 13px; }
.m-install-foot a { color: var(--text-secondary); text-decoration: underline; }
.m-install-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: m-install-spin .8s linear infinite;
}
@keyframes m-install-spin { to { transform: rotate(360deg); } }
